local tArgs = {...}
local packages = config.load("/etc/tpm/package.dat")
local packageInstalled = config.load("/etc/tpm/packageInstalled.dat")

if not security.getSU() then
 exception.throw("RestrictedOpsException")
 return
end

if not packages then
 gui.printAppInfo("tpm", "package.dat is missing or corrupt")
 log.writeMessage("package.dat unable to be traversed")
 return
elseif not packageInstalled then
 shell.executeScript("/etc/scripts/tpm-recache.tsf")
end

if search.findValue(tArgs, "available") then
 gui.printAppInfo("tpm", "traversing package.dat")
 for k, v in pairs(packages) do
  gui.printAppInfo("tpm", "found package identifier "..v.name)
 end
elseif search.findValue(tArgs, "installed") then
 gui.printAppInfo("tpm", "traversing packageInstalled.dat")
 for k, v in pairs(packageInstalled) do
  gui.printAppInfo("tpm", "found package identifier "..v)
 end
else
 gui.printAppInfo("tpm", "specify listing type")
end